//
//  main.swift
//  PerfectTemplate
//
//  Created by Kyle Jessup on 2015-11-05.
//	Copyright (C) 2015 PerfectlySoft, Inc.
//
//===----------------------------------------------------------------------===//
//
// This source file is part of the Perfect.org open source project
//
// Copyright (c) 2015 - 2016 PerfectlySoft Inc. and the Perfect project authors
// Licensed under Apache License v2.0
//
// See http://perfect.org/licensing.html for license information
//
//===----------------------------------------------------------------------===//
//

import PerfectHTTP
import PerfectHTTPServer
import PerfectRequestLogger
import MySQLStORM

// Create HTTP server.

MySQLConnector.host = "localhost";

MySQLConnector.username = "root";//数据库用户名

MySQLConnector.password = "root";//数据库密码

MySQLConnector.port = 3306;//数据库端口

MySQLConnector.database = "SwiftPerfectDB";//数据库名

let apiServer = HTTPServer()

apiServer.serverName = "localhost"

apiServer.serverPort = 8888

apiServer.documentRoot = "./webroot"

apiServer.addRoutes(makeLetRoutes())

apiServer.addRoutes(configure())

apiServer.addRoutes(makeMySQLRoutes())

RequestLogFile.location = "./files/myLog.log"

//apiServer.setRequestFilters(makeRequestFilter())

apiServer.setResponseFilters(makeResponseFilter())

do {
    try apiServer.start()
//    try HTTPServer.launch(.server(name:"localhost",port:8080,documentRoot:"/path/to/webroot"))
} catch {
    fatalError("\(error)") // fatal error launching one of the servers
}




